﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Forms;

namespace LegtionMVVM
{
    /// <summary>
    /// <see cref="ViewHelper"/> faciliates various operation of view and view model, such as instantiation, etc.
    /// </summary>
    public class ViewHelper
    {
        public virtual TView Show<TView, TViewModel>()
            where TView : Form
            where TViewModel : NotifyPropertyChanged
        {
            TViewModel viewModel;
            TView view = Document.CreateDocument<TView, TViewModel>(out viewModel);
            view.Show();
            return view;
        }
        public virtual TView Show<TView, TViewModel>(out TViewModel viewModel)
            where TView : Form
            where TViewModel : NotifyPropertyChanged
        {
            viewModel = null;
            TView view = Document.CreateDocument<TView, TViewModel>(out viewModel);
            view.Show();
            return view;
        }
        public virtual DialogResult ShowDialog<TView, TViewModel>()
            where TView : Form
            where TViewModel : NotifyPropertyChanged
        {
            TViewModel viewModel;
            return Document.CreateDocument<TView, TViewModel>(out viewModel).ShowDialog();
        }
 
    }
    public class Presenter
    {
        protected static readonly ViewHelper ViewHelper = new ViewHelper();
    }
  
}
